<template>
	<view class="container">
		<view class="tabbar">
			<image class="tabbar-image" src="https://app.yycjkb.cn/index/fujiajia/tabbar.png" mode=""></image>
			<view :class="['tabbar-item',{'tab-active': index === currentIndex}]" v-for="(item, index) in tabList"
						:key="index" @tap="switchTab(index)">
				<img :src="item.iconPath" alt="" class="tab-img" v-if="index !== currentIndex"/>
				<img :src="item.selectedIconPath" alt="" class="tab-active-img" v-if="index === currentIndex"/>
				<view :class="['tabbar-text', {'tabbar-text-active': index === currentIndex}]">
					{{item.title}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			currentIndex: {
				type: Number
			}
		},
		data() {
			return {
				tabList: [
					{
						iconPath: "https://app.yycjkb.cn/index/fujiajia/home.png",
						selectedIconPath: "https://app.yycjkb.cn/index/fujiajia/home.png",
						title: "首页"
					},
					{
						iconPath: "https://app.yycjkb.cn/index/fujiajia/category.png",
						selectedIconPath: "https://app.yycjkb.cn/index/fujiajia/category.png",
						title: "分类"
					},
					{
						iconPath: "https://app.yycjkb.cn/index/fujiajia/my.png",
						selectedIconPath: "https://app.yycjkb.cn/index/fujiajia/my.png",
						title: "我的"
					}
				]
			}
		},
		methods: {
			switchTab(index) {
				console.log('xxxx'+index)
				if(index === 0) {
					uni.switchTab({
						url: '/pages/home/index'
					})
				}
				if(index === 1) {
					uni.switchTab({
						url: '/pages/classify/classify'
					})
				}
				if(index === 2) {
					uni.switchTab({
						url: '/pages/my/index'
					})
				}
			}
		}
	};
</script>

<style lang="less" scoped>
	.tabbar {
		position: fixed;
		height: 178rpx;
		width: 750rpx;
		z-index: 999;
		bottom: 0%;
		left: 0%;
		display: flex;
		align-items: center;

		.tabbar-image {
			position: absolute;
			width: 100%;
			height: 100%;
			left: 0%;
			bottom: 0%;
			z-index: -1;
		}

		.tabbar-item {
			z-index: 16;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			width: 33.33%;
			float: left;
			padding: 10rpx 0;
			color: #333;
			text-decoration: none;

			image {
				width: 40rpx;
				height: 40rpx;
				margin-bottom: 5rpx;
			}

			.tabbar-text {
				font-size: 24rpx;
			}
		}

		.active {
			.tabbar-text {
				color: #ff9b45;
			}
		}
	}
	.tab-img {
		width: 48rpx;
		height: 48rpx;
	}
	.tab-active-img {
		width: 88rpx;
		height: 88rpx;
		box-sizing: border-box;
		border: 8rpx solid #fff;
		border-radius: 88rpx;
		background-color: #fff;
	}
	.tab-text-active {
		color: #e13327;
	}
</style>